package com.kk.nb_order.controller.app;

import com.kk.nb_order.exception.OrderNotFoundException;
import com.kk.nb_order.exception.OrderStatusException;
import com.kk.nb_order.service.OrderService;
import com.woniuxy.boot.common.dto.OrderPayDTO;
import com.woniuxy.boot.common.pojo.ResultObj;
import com.woniuxy.boot.common.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: K
 * @Date: 2024/12/14
 */
@RestController("appOrderController")
@RequestMapping("app/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 用户生成订单
     *
     * @param orderVO 此vo中包含用户的信息，车辆的信息，保险的信息和保单的id
     * @return
     */
    @PostMapping("add")
    public ResultObj addOrder(@RequestBody OrderVO orderVO) {
        //此vo中包含用户的信息，车辆的信息，保险的信息和保单的id
        System.out.println(orderVO);
        //添加订单信息
        orderService.addOrder(orderVO);
        return ResultObj.ok();
    }

    /**
     * 用户支付订单
     *
     * @param orderPayDTO
     * @return
     */
    @PostMapping("pay")
    public ResultObj pay(@RequestBody OrderPayDTO orderPayDTO) {
        orderService.pay(orderPayDTO);
        return ResultObj.ok();
    }





}

